% Thomas Bowling
% This function will find the index of a value in a vector (actually the
% index in the vector of a value that is closest to the desired value).
%
% Created: 04/18/2015
% Modified:

function [I,V,E] = find2(vector, value)
% I - index of the found value in vector
% V - vector(I)
% E - absolute value of the difference between value and V

if(length(value) == 1)
    if(value < min(vector) || value > max(vector))
        warning('find2.m: Value is out of the range of vector');
    end
    
    errorVal = abs(vector - value);
    [E,I] = min(errorVal);
    V = vector(I);
else
    [I,V,E] = find3(vector,value);
end
end